
#pragma once

#include "GameLogic.h"

//Converts game from inner representation to ready-for-use html page (or vice versa).
class HtmlConverter
{
	private:
		static const size_t DEFAULT_CELL_WIDTH = 16;
		static const size_t DEFAULT_CELL_HEIGHT = 16;
		//Returns filename of the file with image, corresponded to dot, located at (x, y).
		static const char *GetImage(Game *game, size_t x, size_t y);
		//Appends section with java-scripts (<script> ... </script>).
		static void GenerateScripts(Game *game, Player targetPlayer, std::string &buffer);
		//Appends game table only (<table> ... </table>).
		static void GenerateField(Game *game, Player targetPlayer, std::string &buffer);
		//Appends statistics only.
		static void GenerateStats(Game *game, std::string &buffer);
		//Creates waiting page.
		static void GenerateNotStarted(Game *game, std::string &buffer);
		//Creates page with active game.
		static void GenerateStarted(Game *game, Player targetPlayer, std::string &buffer);
	public:
		//Stores current game object into buffer (as html page).
		//In case of error throws std::exception().
		//Note: serverAddress should be in "http://x.x.x.x:port" format.
		static void GenerateGamePage(Game *game, Player targetPlayer, std::string &buffer);
		//Appends html-page of the muzzle to buffer.
		//In case of error throws std::exception().
		static void GenerateMuzzle(std::string &buffer);
};
